#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   DTC_test.py
@Time    :   2024/09/13 13:31:28
@Author  :   yangliang 
@Version :   1.0
@Contact :   yangliang@chengtech.com
@License :   (C)Copyright 2022-2025
@Desc    :   None
'''

# here put the import lib
from pytest_assume.plugin import assume

import pytest
import datetime
import binascii
import logging
import time
import Set_up
from commDriver.modbus_plc import *
from sympy import I
# from sympy import assuming
from commDriver.TS_CAN import *
import allure
import sys
from collections.abc import Iterable

from sqlalchemy import false
sys.dont_write_bytecode = True

BCM_0x4A0 = 'BCM_0x2F1'
BCM_0x4B3 = 'BDC_BCM_2'
BCM_0x567 = 'BDC_BCM_9'
ESP_0x318 = 'WCBS_ESP_1'
ESP_0x640 = 'WCBS_ESP_3'
ESP_0x650 = 'WCBS_ESP_4'
ESP_0x311 = 'WCBS_ESP_5'
ESP_0x3F0 = 'WCBS_ESP_6'
ESP_0x243 = 'WCBS_ESP_10'
ESP_0x242 = 'WCBS_ESP_13'
EMS_0x280 = 'EMS_5'
TCM_0x3E0 = 'VCU_PDCU_0x230'
EHC_0x523 = 'CDC_EHC_3'
EHC_0x527 = 'CDC_EHC_6'
EHC_0x6E7 = 'CDC_EHC_12'
IPC1_0x620 = 'CDC_IPC1'
CAPE_0x570 = 'PEPS_0x1B1'
SAS_0x180 = 'SAS_1'
St_EngineRunning = ['EMS_5', 'EMS5_St_EngineRunning']

global LOST_enable


def VCAN_Check_F(OBJ, ACAN):
    global LOST_enable

    ID_ststus = {'counter': 0, 'lossframe': False}
    current_add_OK = True

    current_ID = ACAN.contents.FIdentifier

    if (current_ID in [0x385]):  # Done

        CMRR_RR1_St_Failure = ACAN.contents.FData[4] >> 4
        if LOST_enable == 1:
            logging.info(
                f'CMRR_RR1_St_Failure value: {hex(CMRR_RR1_St_Failure)},{time.time()}')
            with assume:
                assert CMRR_RR1_St_Failure == 3
        elif LOST_enable == 2:
            logging.info(
                f'CMRR_RR1_St_Failure value: {hex(CMRR_RR1_St_Failure),{time.time()}}')
            with assume:
                assert CMRR_RR1_St_Failure == 1
        else:
            pass


VCAN_Check_F_ref = TSMasterAPI.OnTx_RxFUNC_CANFD(VCAN_Check_F)
# class SIGNAL_PATH():
#    BCM_0x4A0 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','BCM_0x2F1'
#    BCM_0x4B3 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','BDC_BCM_2'
#    ESP_0x640 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','WCBS_ESP_3'
#    ESP_0x650 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','WCBS_ESP_4'
#    ESP_0x311 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','WCBS_ESP_5'
#    ESP_0x3F0 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','WCBS_ESP_6'
#    ESP_0x242 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','WCBS_ESP_13'
#    EMS_0x280 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','EMS_5'
#    TCM_0x3E0 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','VCU_PDCU_0x230'
#    EHC_0x523 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','CDC_EHC_3'
#    EHC_0x527 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','CDC_EHC_6'
#    EHC_0x6E7 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','CDC_EHC_12'
#    CAPE_0x570 = 'BJEV_B41VEP_ABUS_Matrix_CANFD_V1','CGW','PEPS_0x1B1'


@allure.severity('critical')
class Test_DTC_Phy(object):

    def send_NM_Frame(self, Driver):
        Driver['CAN'].write_db_signal(Set_up.NetName, Set_up.nodeName, 'PEPS_0x1B1', 'PwrMod', 2)
        a = Driver['CAN'].send_CANFrame_Cycle(0x44C,[0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00],500)
        return a

    def stop_FrANFrame_Cycle(self, Driver, Fram):
        logging.info('stop 0x44C NM fram')
        Driver['CAN'].stop_FrANFrame_Cycle(Fram)
        Driver['CAN'].write_db_signal(Set_up.NetName, Set_up.nodeName, 'PEPS_0x1B1', 'PwrMod', 1)
        logging.info('wait 10s')
        time.sleep(60)

    def clearDTC(self, Driver, iStep):
        # 清除DTC故障
        iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x02,0x09], [0x59,0x02,0x09], 1, iStep, False, 'UDS', 'ClearFault')
        iStep = Driver['CAN'].delInitialFailure(iStep,uds_resp)
        return iStep

    def searchDTC(self, Driver, req, DTC_Number, iStep, isTrue, MatureConditionsTime, timeout=2):
        # 查询故障
        with allure.step(f"Step{iStep}: search DTC {binascii.b2a_hex(bytearray(DTC_Number), ' ')}"):
            time.sleep(MatureConditionsTime/1000)
            a, b, c = Driver['UDS'].search_DTC(req, DTC_Number, timeout)
            if isTrue:
                if (b + MatureConditionsTime/1000) > (MatureConditionsTime/1000 + 0.5):
                    logging.error(
                        f"MatureConditionsTime = {MatureConditionsTime/1000 + 0.1}, realtime = {b + MatureConditionsTime/1000}")
                if a != True:
                    logging.error(
                        f"No found DTC{binascii.b2a_hex(bytearray(DTC_Number), ' ')}")
                with assume:
                    assert a == True and (
                        b + MatureConditionsTime/1000) <= (MatureConditionsTime/1000 + 0.5)
            else:
                with assume:
                    assert a == False
            iStep += 1
        return iStep

    def searchDTC2(self, Driver, req, DTC_Number, iStep, isTrue, MatureConditionsTime, timeout=0.1):
        # 查询故障
        with allure.step(f"Step{iStep}: search DTC {binascii.b2a_hex(bytearray(DTC_Number), ' ')}"):
            time.sleep(MatureConditionsTime/1000)
            a, b, c = Driver['UDS'].search_DTC(req, DTC_Number, timeout)
            with assume:
                assert a == False
            if a == False:
                logging.info(
                    f"通讯丢失时间未未满足10times,未发现{binascii.b2a_hex(bytearray(DTC_Number), ' ')}")
                datetim = datetime.datetime.now()
                logging.info("当前时间是{0}".format(datetim).center(30, '*'))

            else:
                logging.error(
                    f"通讯丢失时间未未满足10times,发现{binascii.b2a_hex(bytearray(DTC_Number), ' ')}")
                datetim = datetime.datetime.now()
                logging.info("当前时间是{0}".format(datetim).center(30, '*'))
            iStep += 1
        return iStep

    '''设置信号使能状态'''

    def setSignalEanble(self, Driver, message, status, iStep):
        with allure.step(f'Step{iStep}: set the {message} status to {status}'):
            Driver['CAN'].Enable_rbs_message(
                Set_up.NetName, Set_up.nodeName, message, status)
        iStep += 1
        return iStep

    '''设置信号值'''
    def setSignalValue(Self, Driver, message, signal, value, iStep):
        with allure.step(f'Step{iStep}: set the value of the {signal} in {message} to {value}'):
            Driver['CAN'].write_db_signal(
                Set_up.NetName, Set_up.nodeName, message, signal, value)
            time.sleep(0.2)
            iStep += 1
            readValue = Driver['CAN'].read_db_signal(
                Set_up.NetName, Set_up.nodeName, message, signal)
        return iStep

    def checkDTC(self, Driver, DTCNumber, message, cycleTime, missCount, iStep, signal='', faultValue=0, normalValue=0, settype='enable'):
        req = [0x19, 0x02, 0x09]
        DTC_Number_Exist = DTCNumber + [0x09]
        DTC_Number_NoExist = DTCNumber + [0x08]

        iStep = self.clearDTC(Driver, iStep)
        if settype == 'enable':
            # 停发报文
            iStep = self.setSignalEanble(Driver, message, False, iStep)
        else:
            iStep = self.setSignalValue(Driver, message, signal, faultValue, iStep)
        # 查询故障是否已经产生
        iStep = self.searchDTC(Driver, req, DTC_Number_Exist,iStep, True, cycleTime * missCount)

        if settype == 'enable':
            # 恢复报文
            iStep = self.setSignalEanble(Driver, message, True, iStep)
        else:
            iStep = self.setSignalValue(Driver, message, signal, normalValue, iStep)
        # 查询故障是否已经恢复
        iStep = self.searchDTC(Driver, req, DTC_Number_NoExist, iStep, True, cycleTime * 3, 1)

        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver, iStep)  # 直接下电会读不到历史故障，复位可以读到历史故障


        iStep = self.searchDTC(Driver, req, DTC_Number_NoExist, iStep, True, 100, 1)
        iStep = self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, req, DTC_Number_NoExist, iStep, False, 100, 1)

        return iStep

    def checkDTC2(self, Driver, DTCNumber, message, cycleTime, missCount, iStep, signal='', faultValue=0, normalValue=0, settype='enable'):
        req = [0x19, 0x02, 0x09]
        DTC_Number_Exist = DTCNumber + [0x09]
        DTC_Number_NoExist = DTCNumber + [0x08]
        Fram = self.send_NM_Frame(Driver)
        time.sleep(0.5)

        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, '1001', '5001', 0, iStep)
        iStep = self.clearDTC(Driver, iStep)
        time.sleep(0.5)
        if settype == 'enable':
            # 停发报文
            iStep = self.setSignalEanble(Driver, message, False, iStep)
        else:
            iStep = self.setSignalValue(
                Driver, message, signal, faultValue, iStep)
        # 查询故障是否已经产生
        iStep = self.searchDTC2(Driver, req, DTC_Number_Exist, iStep, True, cycleTime * missCount)

        if settype == 'enable':
            # 停发报文
            iStep = self.setSignalEanble(Driver, message, True, iStep)
        else:
            iStep = self.setSignalValue(Driver, message, signal, normalValue, iStep)
        # 停发网络报文
        # 雷达走下电流程后停止工作 （报文停发，有车身报文时电流在0.1A，无车身报文时电流在0.04A）
        self.stop_FrANFrame_Cycle(Driver, Fram)
        return iStep

    def dtc_time_check(self, Driver, ex_dtc_list, timeout=5):
        '''
        输入故障码和期望状态
        循环请求 19服务,当读到dtc码或超时5s仍然无DTC码时中断
        '''
        global total_time
        flag = True
        time_start = time.time()
        while flag:
            if time.time() - time_start <= timeout:
                uds_rep, size = Driver['UDS'].req_and_res_can(
                    [0x19, 0x02, 0x0B], 3, enable_print=False)
                act_dtc_list = []
                if len(uds_rep) >= 7:
                    for i in range(int((len(uds_rep)-3)/4)):
                        act_dtc_list = uds_rep[3+i:7+i]
                        i += 4
                        if set(ex_dtc_list).issubset(set(act_dtc_list)):
                            time_end = time.time()
                            total_time = round(time_end - time_start, 3)
                            # print('totally cost', total_time, 's. DTC_status:', uds_rep[3:7])
                            readstr = binascii.b2a_hex(
                                bytearray(uds_rep[3:]), ' ')
                            logging.info(
                                'total time cost :{0} s ---,DTC_status<<<{1}>>>\n'.format(str(total_time), readstr))
                            flag = False
            else:
                flag = False
                time_end = time.time()
                total_time = round(time_end - time_start, 3)
                logging.warning('Overtime, No DTC code output!')
                with assume:
                    assert total_time < timeout
        return total_time

    @allure.title('Test master over voltage DTC in default session')
    @allure.description('Test master over voltage DTC in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_Master_Overvoltage_DTC_Default_Phy(self,action,Driver):
        req = [0x19,0x02,0x09]
        DTC_Number = [0x98,0x7A,0x17]
        iStep = 1
        time.sleep(2)
        self.clearDTC(Driver, iStep)
        # 设置电压为8v 制造低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 17, 1, iStep)
        # 查询低压故障是否已经产生
        iStep = self.searchDTC(Driver, req, DTC_Number + [0x09], iStep, True, 1000)
        # 恢复电压为13v
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)
        # 查询故障是否已经恢复
        iStep = self.searchDTC(Driver, req, DTC_Number + [0x08], iStep, True, 1000)

        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, req, DTC_Number + [0x08], iStep, True, 100, 1)
        iStep = self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, req, DTC_Number + [0x08], iStep, False, 100, 1)
    
    @allure.title('Test master under voltage DTC in default session')
    @allure.description('Test master under voltage DTC in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_Master_Undervoltage_DTC_Default_Phy(self,action,Driver):
        req = [0x19,0x02,0x09]
        DTC_Number = [0x98,0x7A,0x16]
        iStep = 1
        time.sleep(2)
        self.clearDTC(Driver, iStep)
        # 设置电压为8v 制造低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8, 1, iStep)
        # 查询低压故障是否已经产生
        iStep = self.searchDTC(Driver, req, DTC_Number + [0x09], iStep, True, 1000)
        # 恢复电压为13v
        iStep = Driver['CAN'].SetVolt(Driver, 13, 1, iStep)
        # 查询故障是否已经恢复
        iStep = self.searchDTC(Driver, req, DTC_Number + [0x08], iStep, True, 1000)

        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)

        iStep = self.searchDTC(Driver, req, DTC_Number + [0x08], iStep, True, 100, 1)
        iStep = self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, req, DTC_Number + [0x08], iStep, False, 100, 1)

    
    @allure.title('Test Vehicle CAN busoff with canh connected to canl in default session')
    @allure.description('Test Vehicle CAN busoff with canh connected to canl in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_DTC_VCAN_BUSOFF_CanHCanL_Default_Phy(self,action,Driver):
        DTC_Number = [0xF2,0x4C,0x88]
        iStep = 1
        time.sleep(2)
        self.clearDTC(Driver, iStep)

        Driver['CAN'].V_ConnectCanH_CanL(True, iStep)
        Driver['CAN'].V_ConnectCanH_CanL(False, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 300, 1)
   
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)

        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, False, 100, 1)

    
    @allure.title('Test Vehicle CAN busoff with canh connected to gnd in default session')
    @allure.description('Test Vehicle CAN busoff with canh connected to gnd in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_DTC_VCAN_BUSOFF_CanHGnd_Default_Phy(self,action,Driver):
        DTC_Number = [0xF2,0x4C,0x88]
        iStep = 1
        time.sleep(2)
        self.clearDTC(Driver, iStep)

        Driver['CAN'].V_ConnectCanH_GND(True, iStep)
        Driver['CAN'].V_ConnectCanH_GND(False, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 300, 1)
   
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)

        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, False, 100, 1)

    
    @allure.title('Test Vehicle CAN busoff with canl connected to vcc in default session')
    @allure.description('Test Vehicle CAN busoff with canl connected to vcc in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_DTC_VCAN_BUSOFF_CanLVcc_Default_Phy(self,action,Driver):
        DTC_Number = [0xF2,0x4C,0x88]
        iStep = 1
        time.sleep(2)
        self.clearDTC(Driver, iStep)

        Driver['CAN'].V_ConnectCanL_Vcc(True, iStep)
        Driver['CAN'].V_ConnectCanL_Vcc(False, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 300, 1)
   
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)

        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, False, 100, 1)

    @allure.title('Test Private CAN busoff with canh connected to canl in default session')
    @allure.description('Test Private CAN busoff with canh connected to canl in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_DTC_PCAN_BUSOFF_CanHCanL_Default_Phy(self,action,Driver):
        DTC_Number = [0xF2,0x4F,0x88]
        iStep = 1
        time.sleep(2)
        self.clearDTC(Driver, iStep)

        Driver['CAN'].P_ConnectCanH_CanL(True, iStep)
        Driver['CAN'].P_ConnectCanH_CanL(False, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 300, 1)
   
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)

        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, False, 100, 1)

    
    @allure.title('Test Private CAN busoff with canh connected to gnd in default session')
    @allure.description('Test Private CAN busoff with canh connected to gnd in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_DTC_PCAN_BUSOFF_CanHGnd_Default_Phy(self,action,Driver):
        DTC_Number = [0xF2,0x4F,0x88]
        iStep = 1
        time.sleep(2)
        self.clearDTC(Driver, iStep)

        Driver['CAN'].P_ConnectCanH_GND(True, iStep)
        Driver['CAN'].P_ConnectCanH_GND(False, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 300, 1)
   
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)

        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, False, 100, 1)

    
    @allure.title('Test Private CAN busoff with canl connected to vcc in default session')
    @allure.description('Test Private CAN busoff with canl connected to vcc in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_DTC_PCAN_BUSOFF_CanLVcc_Default_Phy(self,action,Driver):
        DTC_Number = [0xF2,0x4F,0x88]
        iStep = 1
        time.sleep(2)
        self.clearDTC(Driver, iStep)

        Driver['CAN'].P_ConnectCanL_Vcc(True, iStep)
        Driver['CAN'].P_ConnectCanL_Vcc(False, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 300, 1)
   
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)

        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTC_Number + [0x08], iStep, False, 100, 1)

    
    @allure.title('Test lost communication with BCM by lost 0x2F1 message in default session')
    @allure.description('Test lost communication with BCM by lost 0x2F1 message in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_lostcommunicationwithBCM_Default_Phy(self, action, Driver):
        DTCNumber = [0xF2, 0x43, 0x87]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'BCM_0x2F1', 50, 10, iStep)

    @allure.title('Test Checksum_BCM error by 0x2F1 Checksum Error in default session')
    @allure.description('Test Checksum_BCM error by 0x2F1 Checksum Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x2F1_Checksum_Error_Default_Phy(self,action,Driver):
        DTCNumber = [0xF2, 0x43, 0x83]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x2F1_checksum_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 500, 1)
        # 恢复故障
        Driver['CAN'].set_0x2F1_checksum_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 150, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Rollingcounter_BCM error by 0x2F1 Rollingcounter_BCM Error in default session')
    @allure.description('Test Rollingcounter_BCM error by 0x2F1 Rollingcounter_BCM Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x2F1_rolling_counter_error_Default_Phy(self,action,Driver):
        DTCNumber = [0xF2, 0x43, 0x82]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x2F1_rolling_counter_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 500, 1)
        # 恢复故障
        Driver['CAN'].set_0x2F1_rolling_counter_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 150, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    
    @allure.title('Test lost communication with PBM by lost 0x183 message in default session')
    @allure.description('Test lost communication with PBM by lost 0x183 message in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_lost_0x183_Default_Phy(self, action, Driver):
        DTCNumber = [0xF2, 0x40, 0x87]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'PBM_0x183', 20, 10, iStep)

    @allure.title('Test lost communication with PBM by lost 0x185 message in default session')
    @allure.description('Test lost communication with PBM by lost 0x185 message in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_lost_0x185_Default_Phy(self, action, Driver):
        DTCNumber = [0xF2, 0x40, 0x87]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'PBM_0x185', 20, 10, iStep)

    @allure.title('Test lost communication with PBM by lost 0x186 message in default session')
    @allure.description('Test lost communication with PBM by lost 0x186 message in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_lost_0x186_Default_Phy(self, action, Driver):
        DTCNumber = [0xF2, 0x40, 0x87]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'PBM_0x186', 20, 10, iStep)

    @allure.title('Test Invalid vehiclel speed  reported by PBM in default session')
    @allure.description('Test Invalid vehiclel speed  reported by PBM in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_Invalidvehiclelspeed_0x185_Default_Phy(self, action, Driver):
        DTCNumber = [0xF2, 0x40, 0x81]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'PBM_0x185', 20, 10, iStep, 'VehSpdVld', 2, 1, 'value')

    @allure.title('Test Invalid vehiclel speed  reported by PBM in default session')
    @allure.description('Test Invalid vehiclel speed  reported by PBM in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_Invalidvehiclelspeed_0x183_Default_Phy(self, action, Driver):
        DTCNumber = [0xF2, 0x41, 0x81]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'PBM_0x183', 20, 10, iStep, 'RctbAvl', 1, 0, 'value')


    @allure.title('Test Checksum_PBM error by 0x183 Checksum Error in default session')
    @allure.description('Test Checksum_PBM error by 0x183 Checksum Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x183_Checksum_Error_Default_Phy(self,action,Driver):
        DTCNumber = [0xF2, 0x40, 0x83]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x183_checksum_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 200, 1)
        # 恢复故障
        Driver['CAN'].set_0x183_checksum_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 60, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Checksum_PBM error by 0x185 Checksum Error in default session')
    @allure.description('Test Checksum_PBM error by 0x185 Checksum Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x185_Checksum_Error_Default_Phy(self,action,Driver):
        DTCNumber = [0xF2, 0x40, 0x83]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x185_checksum_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 200, 1)
        # 恢复故障
        Driver['CAN'].set_0x185_checksum_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 60, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Checksum_PBM error by 0x186 Checksum Error in default session')
    @allure.description('Test Checksum_PBM error by 0x186 Checksum Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x186_Checksum_Error_Default_Phy(self,action,Driver):
        DTCNumber = [0xF2, 0x40, 0x83]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x186_checksum_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 200, 1)
        # 恢复故障
        Driver['CAN'].set_0x186_checksum_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 60, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Rollingcounter_PBM error by 0x183 Rollingcounter Error in default session')
    @allure.description('Test Rollingcounter_PBM error by 0x183 Rollingcounter Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x183_rolling_counter_error_Default_Phy(self,action,Driver):
        DTCNumber = [0xF2, 0x40, 0x82]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x183_rolling_counter_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 200, 1)
        # 恢复故障
        Driver['CAN'].set_0x183_rolling_counter_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 60, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Rollingcounter_PBM error by 0x185 Rollingcounter Error in default session')
    @allure.description('Test Rollingcounter_PBM error by 0x185 Rollingcounter Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x185_rolling_counter_error_Default_Phy(self,action,Driver):
        DTCNumber = [0xF2, 0x40, 0x82]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x185_rolling_counter_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 200, 1)
        # 恢复故障
        Driver['CAN'].set_0x185_rolling_counter_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 60, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Rollingcounter_PBM error by 0x186 Rollingcounter Error in default session')
    @allure.description('Test Rollingcounter_PBM error by 0x186 Rollingcounter Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x186_rolling_counter_error_Default_Phy(self,action,Driver):
        DTCNumber = [0xF2, 0x40, 0x82]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x186_rolling_counter_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 200, 1)
        # 恢复故障
        Driver['CAN'].set_0x186_rolling_counter_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 60, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test lost communication with VCU by lost VCU_PDCU_0x230 message in default session')
    @allure.description('Test lost communication with VCU by lost VCU_PDCU_0x230 message in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_lost_0x230_Default_Phy(self, action, Driver):
        DTCNumber = [0xD7, 0x6F, 0x87]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'VCU_PDCU_0x230', 10, 10, iStep)

    @allure.title('Test lost communication with VCU by lost VCU_0x210 message in default session')
    @allure.description('Test lost communication with VCU by lost VCU_0x210 message in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_lost_0x210_Default_Phy(self, action, Driver):
        DTCNumber = [0xD7, 0x6F, 0x87]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'VCU_MCU_PDCU_0x210', 10, 10, iStep)

    @allure.title('Test Invalid gear position  reported by VCU in default session')
    @allure.description('Test Invalid gear position  reported by VCU in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_Invalidgearpositionreported_0x185_Default_Phy(self, action, Driver):
        DTCNumber = [0xD7, 0x6F, 0x81]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'VCU_PDCU_0x230', 10, 10, iStep, 'VCU_STRATEGY_SHIFT_POSN_FLAG', 3, 0, 'value')

    
    @allure.title('Test Checksum_VCU error by 0x230 Checksum Error in default session')
    @allure.description('Test Checksum_VCU error by 0x230 Checksum Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x230_Checksum_Error_Default_Phy(self,action,Driver):
        DTCNumber = [0xD7, 0x6F, 0x83]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x230_checksum_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 100, 1)
        # 恢复故障
        Driver['CAN'].set_0x230_checksum_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 30, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Checksum_VCU error by 0x210 Checksum Error in default session')
    @allure.description('Test Checksum_VCU error by 0x210 Checksum Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x210_Checksum_Error_Default_Phy(self,action,Driver):
        DTCNumber = [0xD7, 0x6F, 0x83]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x210_checksum_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 100, 1)
        # 恢复故障
        Driver['CAN'].set_0x210_checksum_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 30, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Rollingcounter_VCU error by 0x210 Rollingcounter Error in default session')
    @allure.description('Test Rollingcounter_VCU error by 0x210 Rollingcounter Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x210_rolling_counter_error_Default_Phy(self,action,Driver):
        DTCNumber = [0xD7, 0x6F, 0x82]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x210_rolling_counter_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 100, 1)
        # 恢复故障
        Driver['CAN'].set_0x210_rolling_counter_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 30, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Rollingcounter_VCU error by 0x230 Rollingcounter Error in default session')
    @allure.description('Test Rollingcounter_VCU error by 0x230 Rollingcounter Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x230_rolling_counter_error_Default_Phy(self,action,Driver):
        DTCNumber = [0xD7, 0x6F, 0x82]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x230_rolling_counter_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 100, 1)
        # 恢复故障
        Driver['CAN'].set_0x230_rolling_counter_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 30, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test lost communication with YRS by lost YRS_0x19A message in default session')
    @allure.description('Test lost communication with YRS by lost YRS_0x19A message in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_lost_0x19A_Default_Phy(self, action, Driver):
        DTCNumber = [0xD7, 0x64, 0x87]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'YRS_0x19A', 20, 10, iStep)

    @allure.title('Test Invalid vehicle dynamic LateralAcce value reported by YRS in default session')
    @allure.description('Test Invalid vehicle dynamic LateralAcce value reported by YRS in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_InvalidvehicledynamicLateralAccevaluereported_Default_Phy(self, action, Driver):
        DTCNumber = [0xD7, 0x64, 0x81]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'YRS_0x19A', 20, 10, iStep, 'LatSnsrSts', 2, 1, 'value')
    
    @allure.title('Test Invalid vehicle dynamic LongitudeAcc value reported by YRS in default session')
    @allure.description('Test Invalid vehicle dynamic LongitudeAcc value reported by YRS in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_InvalidvehicledynamicLongitudeAccvaluereported_Default_Phy(self, action, Driver):
        DTCNumber = [0xD7, 0x65, 0x81]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'YRS_0x19A', 20, 10, iStep, 'LgtSnsrSts', 2, 1, 'value')

    @allure.title('Test Invalid vehicle dynamic yaw rate value reported by YRS in default session')
    @allure.description('Test Invalid vehicle dynamic yaw rate value reported by YRS in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_InvalidvehicledynamicLateralAccevaluereported_Default_Phy(self, action, Driver):
        DTCNumber = [0xD7, 0x66, 0x81]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'YRS_0x19A', 20, 10, iStep, 'YawRateSnsrSts', 2, 1, 'value')

    
    @allure.title('Test Checksum_YRS error by 0x19A Checksum Error in default session')
    @allure.description('Test Checksum_YRS error by 0x19A Checksum Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x19A_Checksum_Error_Default_Phy(self,action,Driver):
        DTCNumber = [0xD7, 0x64, 0x83]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x19A_checksum_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 200, 1)
        # 恢复故障
        Driver['CAN'].set_0x19A_checksum_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 60, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Rollingcounter_YRS error by 0x19A Rollingcounter Error in default session')
    @allure.description('Test Rollingcounter_YRS error by 0x19A Rollingcounter Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x19A_rolling_counter_error_Default_Phy(self,action,Driver):
        DTCNumber = [0xD7, 0x64, 0x82]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x19A_rolling_counter_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 200, 1)
        # 恢复故障
        Driver['CAN'].set_0x19A_rolling_counter_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 60, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test lost communication with PEPS by lost PEPS_0x1B1 message in default session')
    @allure.description('Test lost communication with PEPS by lost PEPS_0x1B1 message in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_lost_0x1B1_Default_Phy(self, action, Driver):
        DTCNumber = [0xF2, 0x48, 0x87]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'PEPS_0x1B1', 20, 10, iStep)

    @allure.title('Test invalid power mode by PEPS in default session')
    @allure.description('Test invalid power mode by PEPS in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_invalidpowermode_Default_Phy(self, action, Driver):
        DTCNumber = [0xF2, 0x48, 0x81]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'PEPS_0x1B1', 20, 10, iStep, 'PwrModVld', 1, 2, 'value')

    @allure.title('Test Checksum_YRS error by 0x1B1 Checksum Error in default session')
    @allure.description('Test Checksum_YRS error by 0x1B1 Checksum Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x1B1_Checksum_Error_Default_Phy(self,action,Driver):
        DTCNumber = [0xF2, 0x48, 0x83]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x1B1_checksum_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 200, 1)
        # 恢复故障
        Driver['CAN'].set_0x1B1_checksum_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 60, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Rollingcounter_YRS error by 0x1B1 Rollingcounter Error in default session')
    @allure.description('Test Rollingcounter_YRS error by 0x1B1 Rollingcounter Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x1B1_rolling_counter_error_Default_Phy(self,action,Driver):
        DTCNumber = [0xF2, 0x48, 0x82]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x1B1_rolling_counter_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 200, 1)
        # 恢复故障
        Driver['CAN'].set_0x1B1_rolling_counter_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 60, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    
    @allure.title('Test lost communication with EPS by lost EPS_0x150 message in default session')
    @allure.description('Test lost communication with EPS by lost EPS_0x150 message in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_lost_0x150_Default_Phy(self, action, Driver):
        DTCNumber = [0xD7, 0x6A, 0x87]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'EPS_0x150', 10, 10, iStep)

    @allure.title('Test Invalid angle of steering wheel value reported by EPS in default session')
    @allure.description('Test Invalid angle of steering wheel value reported by EPS in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_Invalidangleofsteeringwheelvaluereported_Default_Phy(self, action, Driver):
        DTCNumber = [0xD7, 0x6A, 0x81]
        iStep = 1
        iStep = self.checkDTC(Driver, DTCNumber, 'EPS_0x150', 10, 10, iStep, 'SteerWhlAgVld', 2, 1, 'value')

    @allure.title('Test Checksum_YRS error by 0x150 Checksum Error in default session')
    @allure.description('Test Checksum_YRS error by 0x150 Checksum Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x150_Checksum_Error_Default_Phy(self,action,Driver):
        DTCNumber = [0xD7, 0x6A, 0x83]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x150_checksum_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 100, 1)
        # 恢复故障
        Driver['CAN'].set_0x150_checksum_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 30, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)

    @allure.title('Test Rollingcounter_YRS error by 0x150 Rollingcounter Error in default session')
    @allure.description('Test Rollingcounter_YRS error by 0x150 Rollingcounter Error in default sessionin with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_0x150_rolling_counter_error_Default_Phy(self,action,Driver):
        DTCNumber = [0xD7, 0x6A, 0x82]
        iStep = 1
        self.clearDTC(Driver, iStep)
        # 制造故障 
        Driver['CAN'].set_0x150_rolling_counter_error(True)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x09], iStep, True, 100, 1)
        # 恢复故障
        Driver['CAN'].set_0x150_rolling_counter_error(False)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 30, 1)
        # 重启产品
        iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, True, 100, 1)
        self.clearDTC(Driver, iStep)
        iStep = self.searchDTC(Driver, [0x19,0x02,0x09], DTCNumber + [0x08], iStep, False, 100, 1)